home *** CD-ROM | disk | FTP | other *** search
- /* ALAdd.M */
-
- OPT MODULE
- OPT EXPORT
-
- /* This module contains all the functions to build the temp file to send. */
- MODULE 'dos/dos'
- MODULE 'other/allog'
-
- DEF temp_file:PTR TO CHAR
-
- /*
- * Clears the temp file out, also allocates the temp_file string if necissary
- */
- PROC clear_tmp_file ()
- DEF fd
-
- IF (temp_file = NIL)
- temp_file := String (11)
- StrCopy (temp_file, 'T:AList.tmp')
- ENDIF
-
- fd := Open (temp_file, MODE_NEWFILE)
- IF (fd = NIL)
- /* We'll be generating a WHOLE lot of problems if we can't get this open! */
- log_message ('Unable to open work file!\n', LOG_FATAL)
- CleanUp (50)
- ELSE
- Close (fd)
- ENDIF
- ENDPROC
-
-
- /*
- * Adds a string to the temporary work file.
- *
- * Must first call clear_tmp_file() before using this!
- */
- PROC add_tmp_file (str)
- DEF fd
-
- IF (IF (str = NIL) THEN FALSE ELSE (str[0] = NIL)) THEN RETURN
-
- /* Not the most efficient way to do this, but the safest */
- fd := Open (temp_file, MODE_READWRITE)
- IF (fd)
- Seek (fd, 0, OFFSET_END)
- Fwrite (fd, str, 1, StrLen (str))
- Close (fd)
- ENDIF
- ENDPROC
-
-
- /*
- * Calls add_tmp_file for a chain of strings
- */
- PROC fill_tmp_file (str:PTR TO CHAR)
- WHILE (str)
- add_tmp_file (str)
- str := Next (str)
- ENDWHILE
- ENDPROC
-
-
- /*
- * Not really for handling temp files, but used in conjunction...
- *
- * Adds an object onto the tail of a chain, specifically, estrings, returning the list head.
- */
- PROC add_link (str1, str2)
- DEF str3
-
- IF (str1 = NIL) THEN RETURN str2
-
- str3 := str1
- WHILE (Next (str3))
- str3 := Next (str3)
- ENDWHILE
-
- Link (str3, str2)
- ENDPROC str1
-
-
- /*
- * Adds the help command(s) specified to the tmp file
- */
- PROC add_tmp_help (str:PTR TO CHAR)
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'HELP', 4))
- add_tmp_file ('\tHELP [cmd]\t\tReturns help for all commands, or only one\n' +
- '\t\t\t\tspecific command.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'INDEX', 5))
- add_tmp_file ('\tINDEX\t\t\tProduces a list of all the visible lists on\n' +
- '\t\t\t\tthis server, along with the one-line\n'+
- '\t\t\t\tdescriptions for each.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'LIST', 4))
- add_tmp_file ('\tLIST [addr]\t\tProduces a list of all the lists you are\n' +
- '\t\t\t\tsubscribed to, or all the visible lists\n' +
- '\t\t\t\t<addr> is subscribed to.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'WHO', 3))
- add_tmp_file ('\tWHO [list]\t\tLists the members of a list, if allowed.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'ADD', 3))
- add_tmp_file ('\tADD [list][addr]\tAdds <addr> to the given list, if allowed.\n'+
- '\t\t\t\tIf no <addr> is specified, the email address\n'+
- '\t\t\t\tyou send this command from will be used in\n'+
- '\t\t\t\tits place.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'DELETE', 6))
- add_tmp_file ('\tDELETE [list][add]\tRemoves <addr> from the given list, if\n'+
- '\t\t\t\tallowed. If no <addr> is specified, the\n'+
- '\t\t\t\temail address you send this command from\n'+
- '\t\t\t\twill be used in its place.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'SUBSCRIBE', 9))
- add_tmp_file ('\tSUBSCRIBE [list][addr]\tSee ADD.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'UNSUBSCRIBE', 11))
- add_tmp_file ('\tUNSUBSCRIBE [list][addr] See DELETE.\n\n')
- ENDIF
- IF (IF (str[0] = 0) THEN TRUE ELSE StrCmp (str, 'INFO', 4))
- add_tmp_file ('\tINFO [list]\t\tSimilar to LONGINDEX, but for a specific list.\n\n')
- ENDIF
- IF (str[0] = 0)
- add_tmp_file ('\nNOT YET IMPLIMENTED:\n\n')
- add_tmp_file ('\tLONGINDEX\t\tLists a multiple-line description for all\n'+
- '\t\t\t\tvisible lists, if they have one, and if\n'+
- '\t\t\t\tit is allowed.\n\n')
- add_tmp_file ('\tADD-ALL [addr]\t\tAdds the <addr> to every visible list, if\n'+
- '\t\t\t\tallowed. If no <addr> is specified, the\n'+
- '\t\t\t\temail address you send this command from\n'+
- '\t\t\t\twill be used in its place.\n\n')
- add_tmp_file ('\tDELETE-ALL [addr]\tRemoves the <addr> from every list it is\n'+
- '\t\t\t\tsubscribed to, if allowed. If no <addr> is\n'+
- '\t\t\t\tspecified, the email address you send this\n'+
- '\t\t\t\tcommand from will be used in its place.\n\n')
- add_tmp_file ('\tFAQ [list]\t\tRetrieves the FAQ for the given list.\n\n')
- add_tmp_file ('\tDIR [list]\t\tRetrieves the directory listing for the given\n'+
- '\t\t\t\tlist, if there is one, and if allowed.\n\n')
- add_tmp_file ('\tGET [list] file\t\tRetrieves the <file> from the list\as\n'+
- '\t\t\t\tdirectory, if it has one, and if it is\n'+
- '\t\t\t\tallowed. The file will be uuencoded\n'+
- '\t\t\t\tbefore sending.\n\n')
- add_tmp_file ('\tPUT [list] file\t\tUudecodes and stores the rest of the message\n'+
- '\t\t\t\tunder the filename <file> in the list\as\n'+
- '\t\t\t\tdirectory, if it has one, and if you are\n'+
- '\t\t\t\tallowed to.\n\n')
- add_tmp_file ('\tAPPROVE password cmd\tSpecified a password for commands which\n'+
- '\t\t\t\trequire one.\n\n')
- add_tmp_file ('\tSETKEY [list] [user]\tTreats the rest of the file, up to the next\n'+
- '\t\t\t\tblank line, as the user\as public key.\n'+
- '\t\t\t\tRequired on some encoded lists for\n'+
- '\t\t\t\tencryption before sending.\n\n')
- add_tmp_file ('\tPUTFAQ [list]\t\tConsiders the rest of the mail, up until\n' +
- '\t\t\t\tENDFAQ on a line by itself, to be the new\n' +
- '\t\t\t\tFAQ for the list. Requires the list\as\n'+
- '\t\t\t\tadministration password.\n\n')
- add_tmp_file ('\tCONFIG [list]\t\tReturns the current config file for the list.\n'+
- '\t\t\t\tRequires the list\as administration password.\n\n')
- add_tmp_file ('\tNEWCONFIG [list]\tConsiders the rest of the mail, up until\n'+
- '\t\t\t\tENDCONFIG on a line by itself, to be the new\n'+
- '\t\t\t\tconfig file for the list. Requires the\n'+
- '\t\t\t\tlist\as administration password.\n\n')
- ENDIF
- ENDPROC
-
-
- /*
- * Another one that is only here because it's about the best place for it.
- *
- * Counts the number of times 'ch' appears in 'str'.
- */
- PROC count (str:PTR TO CHAR, ch)
- DEF x, y
-
- x := y := 0
-
- WHILE (str[x])
- IF (str[x] = ch) THEN INC y
- INC x
- ENDWHILE
- ENDPROC y
-
-
-